home *** CD-ROM | disk | FTP | other *** search
- * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
- * The C++ Answer Book */
- * Tony Hansen */
- * All rights reserved. */
- include <process.h>
- include <debug.h> /* DELETE */
- / Set the pseudo-clock.
- oid process::stime(unsigned long t)
-
- if (debug) /*DELETE*/ cerr << "process" << this << "::stime(" << t << ")\n";
- t_curtime = t;
-
- // skip past the beginning processes
- for (process **pp = &t_runprocesses;
- *pp && ((*pp)->t_desiredtime == 0);
- pp = &(*pp)->t_next)
- if (debug) /*DELETE*/ cerr << "\t" << (*pp) << "-> desiredtime = " << (*pp)->t_desiredtime << ", skipped\n"
- ;
-
- // move all passed-by processes to a safe place
- process *saveprocs = 0;
- while (*pp && ((*pp)->t_desiredtime <= t))
- {
- if (debug) /*DELETE*/ cerr << "\t" << (*pp) << "-> desiredtime = " << (*pp)->t_desiredtime << ", saved\n";
- process *sv = *pp;
- process *svn = sv->t_next;
- *pp = svn;
- sv->t_next = saveprocs;
- saveprocs = sv;
- }
-
- // move the processes back onto the run queue
- while (saveprocs)
- {
- if (debug) /*DELETE*/ cerr << "\t" << saveprocs << ", shuffled\n";
- process *sv = saveprocs;
- saveprocs = sv->t_next;
- sv->t_desiredtime = 0;
- sv->t_next = t_runprocesses;
- t_runprocesses = sv;
- shufflerunlist();
- }
- if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::stime(" << t << ")\n";
-
-